package com.ourcraft.informationcollectionsystem.utils.statusCode;

import com.ourcraft.informationcollectionsystem.entity.DataReportForm;

public enum DataReportFormStatus {
    NOT_FILL(0),
    NOT_SUBMIT(1),
    WAIT_CITY(2),
    RETURNED_BY_CITY(3),
    WAIT_PROVINCE(4),
    RETURNED_BY_PROVINCE(5),
    PASS(6),
    EXPORT(7);

    public final Integer status;

    DataReportFormStatus(Integer status) {
        this.status = status;
    }

    public DataReportFormStatus save() {
        return switch (this) {
            case NOT_FILL, NOT_SUBMIT -> NOT_SUBMIT;
            case RETURNED_BY_CITY -> RETURNED_BY_CITY;
            case RETURNED_BY_PROVINCE -> RETURNED_BY_PROVINCE;
            default -> null;
        };
    }

    public static DataReportFormStatus build(Integer status) {
        if (status == null) return null;
        return switch (status) {
            case 0 -> NOT_FILL;
            case 1 -> NOT_SUBMIT;
            case 2 -> WAIT_CITY;
            case 3 -> RETURNED_BY_CITY;
            case 4 -> WAIT_PROVINCE;
            case 5 -> RETURNED_BY_PROVINCE;
            case 6 -> PASS;
            case 7 -> EXPORT;
            default -> null;
        };
    }

    public DataReportFormStatus submit() {
        return switch (this) {
            case NOT_FILL, NOT_SUBMIT, RETURNED_BY_CITY, RETURNED_BY_PROVINCE -> WAIT_CITY;
            case PASS -> EXPORT;
            default -> null;
        };
    }

    public DataReportFormStatus pass() {
        return switch (this) {
            case WAIT_CITY -> WAIT_PROVINCE;
            case WAIT_PROVINCE -> PASS;
            default -> null;
        };
    }

    public DataReportFormStatus returned() {
        return switch (this) {
            case WAIT_CITY -> RETURNED_BY_CITY;
            case WAIT_PROVINCE -> RETURNED_BY_PROVINCE;
            default -> null;
        };
    }

}
